<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html>
<html lang="en">
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<!-- qquickitem.cpp -->
  <title>Keys QML 类型 | Qt Quick 5.12.3</title>
  <link rel="stylesheet" type="text/css" href="style/offline-simple.css" />
  <script type="text/javascript">
    document.getElementsByTagName("link").item(0).setAttribute("href", "style/offline.css");
    // loading style sheet breaks anchors that were jumped to before
    // so force jumping to anchor again
    setTimeout(function() {
        var anchor = location.hash;
        // need to jump to different anchor first (e.g. none)
        location.hash = "#";
        setTimeout(function() {
            location.hash = anchor;
        }, 0);
    }, 0);
  </script>
</head>
<body>
<div class="header" id="qtdocheader">
  <div class="main">
    <div class="main-rounded">
      <div class="navigationbar">
        <table><tr>
<td ><a href="../qtdoc/index.html">Qt 5.12</a></td><td ><a href="qtquick-index.html">Qt Quick 模块</a></td><td ><a href="qtquick-qmlmodule.html">QML类型</a></td><td >Keys QML 类型</td></tr></table><table class="buildversion"><tr>
<td id="buildversion" width="100%" align="right"><a href="qtquick-index.html">Qt 5.12.3 参考指南</a></td>
        </tr></table>
      </div>
    </div>
<div class="content">
<div class="line">
<div class="content mainContent">
<div class="sidebar">
<div class="toc">
<h3><a name="toc">目录</a></h3>
<ul>
<li class="level1"><a href="#properties">属性</a></li>
<li class="level1"><a href="#signals">信号</a></li>
<li class="level1"><a href="#details">详细信息</a></li>
<li class="level2"><a href="#example-usage">示例用法</a></li>
<li class="level2"><a href="#key-handling-priorities">Key Handling Priorities</a></li>
</ul>
</div>
<div class="sidebar-content" id="sidebar-content"></div></div>
<h1 class="title">Keys QML 类型</h1>
<span class="subtitle"></span>
<!-- $$$Keys-brief -->
<p>Provides key handling to Items. <a href="#details">更多...</a></p>
<!-- @@@Keys -->
<div class="table"><table class="alignedsummary">
<tr><td class="memItemLeft rightAlign topAlign"> 导入语句：</td><td class="memItemRight bottomAlign"> import QtQuick 2.12</td></tr></table></div><ul>
<li><a href="qml-qtquick-keys-members.html">所有成员的列表，包括继承成员</a></li>
</ul>
<a name="properties"></a>
<h2 id="properties">属性</h2>
<ul>
<li class="fn"><b><b><a href="qml-qtquick-keys.html#enabled-prop">enabled</a></b></b> : bool</li>
<li class="fn"><b><b><a href="qml-qtquick-keys.html#forwardTo-prop">forwardTo</a></b></b> : list&lt;Object&gt;</li>
<li class="fn"><b><b><a href="qml-qtquick-keys.html#priority-prop">priority</a></b></b> : enumeration</li>
</ul>
<a name="signals"></a>
<h2 id="signals">信号</h2>
<ul>
<li class="fn"><b><b><a href="qml-qtquick-keys.html#asteriskPressed-signal">asteriskPressed</a></b></b>(KeyEvent <i>event</i>)</li>
<li class="fn"><b><b><a href="qml-qtquick-keys.html#backPressed-signal">backPressed</a></b></b>(KeyEvent <i>event</i>)</li>
<li class="fn"><b><b><a href="qml-qtquick-keys.html#backtabPressed-signal">backtabPressed</a></b></b>(KeyEvent <i>event</i>)</li>
<li class="fn"><b><b><a href="qml-qtquick-keys.html#callPressed-signal">callPressed</a></b></b>(KeyEvent <i>event</i>)</li>
<li class="fn"><b><b><a href="qml-qtquick-keys.html#cancelPressed-signal">cancelPressed</a></b></b>(KeyEvent <i>event</i>)</li>
<li class="fn"><b><b><a href="qml-qtquick-keys.html#context1Pressed-signal">context1Pressed</a></b></b>(KeyEvent <i>event</i>)</li>
<li class="fn"><b><b><a href="qml-qtquick-keys.html#context2Pressed-signal">context2Pressed</a></b></b>(KeyEvent <i>event</i>)</li>
<li class="fn"><b><b><a href="qml-qtquick-keys.html#context3Pressed-signal">context3Pressed</a></b></b>(KeyEvent <i>event</i>)</li>
<li class="fn"><b><b><a href="qml-qtquick-keys.html#context4Pressed-signal">context4Pressed</a></b></b>(KeyEvent <i>event</i>)</li>
<li class="fn"><b><b><a href="qml-qtquick-keys.html#deletePressed-signal">deletePressed</a></b></b>(KeyEvent <i>event</i>)</li>
<li class="fn"><b><b><a href="qml-qtquick-keys.html#digit0Pressed-signal">digit0Pressed</a></b></b>(KeyEvent <i>event</i>)</li>
<li class="fn"><b><b><a href="qml-qtquick-keys.html#digit1Pressed-signal">digit1Pressed</a></b></b>(KeyEvent <i>event</i>)</li>
<li class="fn"><b><b><a href="qml-qtquick-keys.html#digit2Pressed-signal">digit2Pressed</a></b></b>(KeyEvent <i>event</i>)</li>
<li class="fn"><b><b><a href="qml-qtquick-keys.html#digit3Pressed-signal">digit3Pressed</a></b></b>(KeyEvent <i>event</i>)</li>
<li class="fn"><b><b><a href="qml-qtquick-keys.html#digit4Pressed-signal">digit4Pressed</a></b></b>(KeyEvent <i>event</i>)</li>
<li class="fn"><b><b><a href="qml-qtquick-keys.html#digit5Pressed-signal">digit5Pressed</a></b></b>(KeyEvent <i>event</i>)</li>
<li class="fn"><b><b><a href="qml-qtquick-keys.html#digit6Pressed-signal">digit6Pressed</a></b></b>(KeyEvent <i>event</i>)</li>
<li class="fn"><b><b><a href="qml-qtquick-keys.html#digit7Pressed-signal">digit7Pressed</a></b></b>(KeyEvent <i>event</i>)</li>
<li class="fn"><b><b><a href="qml-qtquick-keys.html#digit8Pressed-signal">digit8Pressed</a></b></b>(KeyEvent <i>event</i>)</li>
<li class="fn"><b><b><a href="qml-qtquick-keys.html#digit9Pressed-signal">digit9Pressed</a></b></b>(KeyEvent <i>event</i>)</li>
<li class="fn"><b><b><a href="qml-qtquick-keys.html#downPressed-signal">downPressed</a></b></b>(KeyEvent <i>event</i>)</li>
<li class="fn"><b><b><a href="qml-qtquick-keys.html#enterPressed-signal">enterPressed</a></b></b>(KeyEvent <i>event</i>)</li>
<li class="fn"><b><b><a href="qml-qtquick-keys.html#escapePressed-signal">escapePressed</a></b></b>(KeyEvent <i>event</i>)</li>
<li class="fn"><b><b><a href="qml-qtquick-keys.html#flipPressed-signal">flipPressed</a></b></b>(KeyEvent <i>event</i>)</li>
<li class="fn"><b><b><a href="qml-qtquick-keys.html#hangupPressed-signal">hangupPressed</a></b></b>(KeyEvent <i>event</i>)</li>
<li class="fn"><b><b><a href="qml-qtquick-keys.html#leftPressed-signal">leftPressed</a></b></b>(KeyEvent <i>event</i>)</li>
<li class="fn"><b><b><a href="qml-qtquick-keys.html#menuPressed-signal">menuPressed</a></b></b>(KeyEvent <i>event</i>)</li>
<li class="fn"><b><b><a href="qml-qtquick-keys.html#noPressed-signal">noPressed</a></b></b>(KeyEvent <i>event</i>)</li>
<li class="fn"><b><b><a href="qml-qtquick-keys.html#pressed-signal">pressed</a></b></b>(KeyEvent <i>event</i>)</li>
<li class="fn"><b><b><a href="qml-qtquick-keys.html#released-signal">released</a></b></b>(KeyEvent <i>event</i>)</li>
<li class="fn"><b><b><a href="qml-qtquick-keys.html#returnPressed-signal">returnPressed</a></b></b>(KeyEvent <i>event</i>)</li>
<li class="fn"><b><b><a href="qml-qtquick-keys.html#rightPressed-signal">rightPressed</a></b></b>(KeyEvent <i>event</i>)</li>
<li class="fn"><b><b><a href="qml-qtquick-keys.html#selectPressed-signal">selectPressed</a></b></b>(KeyEvent <i>event</i>)</li>
<li class="fn"><b><b><a href="qml-qtquick-keys.html#shortcutOverride-signal">shortcutOverride</a></b></b>(KeyEvent <i>event</i>)</li>
<li class="fn"><b><b><a href="qml-qtquick-keys.html#spacePressed-signal">spacePressed</a></b></b>(KeyEvent <i>event</i>)</li>
<li class="fn"><b><b><a href="qml-qtquick-keys.html#tabPressed-signal">tabPressed</a></b></b>(KeyEvent <i>event</i>)</li>
<li class="fn"><b><b><a href="qml-qtquick-keys.html#upPressed-signal">upPressed</a></b></b>(KeyEvent <i>event</i>)</li>
<li class="fn"><b><b><a href="qml-qtquick-keys.html#volumeDownPressed-signal">volumeDownPressed</a></b></b>(KeyEvent <i>event</i>)</li>
<li class="fn"><b><b><a href="qml-qtquick-keys.html#volumeUpPressed-signal">volumeUpPressed</a></b></b>(KeyEvent <i>event</i>)</li>
<li class="fn"><b><b><a href="qml-qtquick-keys.html#yesPressed-signal">yesPressed</a></b></b>(KeyEvent <i>event</i>)</li>
</ul>
<!-- $$$Keys-description -->
<a name="details"></a>
<h2 id="details">详细信息</h2>
<p>All visual primitives support key handling via the Keys attached property. Keys can be handled via the onPressed and onReleased signal properties.</p>
<p>The signal properties have a <a href="qml-qtquick-keyevent.html">KeyEvent</a> parameter, named <i>event</i> which contains details of the event. If a key is handled <i>event.accepted</i> should be set to true to prevent the event from propagating up the item hierarchy.</p>
<a name="example-usage"></a>
<h2 id="example-usage">示例用法</h2>
<p>The following example shows how the general onPressed handler can be used to test for a certain key; in this case, the left cursor key:</p>
<pre class="qml">

  <span class="type"><a href="qml-qtquick-item.html">Item</a></span> {
      <span class="name">anchors</span>.fill: <span class="name">parent</span>
      <span class="name">focus</span>: <span class="number">true</span>
      <span class="name">Keys</span>.onPressed: {
          <span class="keyword">if</span> (<span class="name">event</span>.<span class="name">key</span> <span class="operator">==</span> <span class="name">Qt</span>.<span class="name">Key_Left</span>) {
              <span class="name">console</span>.<span class="name">log</span>(<span class="string">&quot;move left&quot;</span>);
              <span class="name">event</span>.<span class="name">accepted</span> <span class="operator">=</span> <span class="number">true</span>;
          }
      }
  }

</pre>
<p>Some keys may alternatively be handled via specific signal properties, for example <i>onSelectPressed</i>. These handlers automatically set <i>event.accepted</i> to true.</p>
<pre class="qml">

  <span class="type"><a href="qml-qtquick-item.html">Item</a></span> {
      <span class="name">anchors</span>.fill: <span class="name">parent</span>
      <span class="name">focus</span>: <span class="number">true</span>
      <span class="name">Keys</span>.onLeftPressed: <span class="name">console</span>.<span class="name">log</span>(<span class="string">&quot;move left&quot;</span>)
  }

</pre>
<p>See <a href="../qtcore/qt.html#Key-enum">Qt.Key</a> for the list of keyboard codes.</p>
<a name="key-handling-priorities"></a>
<h2 id="key-handling-priorities">Key Handling Priorities</h2>
<p>The Keys attached property can be configured to handle key events before or after the item it is attached to. This makes it possible to intercept events in order to override an item's default behavior, or act as a fallback for keys not handled by the item.</p>
<p>If <a href="qml-qtquick-keys.html#priority-prop">priority</a> is Keys.BeforeItem (default) the order of key event processing is:</p>
<ol class="1" type="1"><li>Items specified in <code>forwardTo</code></li>
<li>specific key handlers, e.g&#x2e; onReturnPressed</li>
<li>onPressed, onReleased handlers</li>
<li>Item specific key handling, e.g&#x2e; <a href="qml-qtquick-textinput.html">TextInput</a> key handling</li>
<li>parent item</li>
</ol>
<p>If priority is Keys.AfterItem the order of key event processing is:</p>
<ol class="1" type="1"><li>Item specific key handling, e.g&#x2e; <a href="qml-qtquick-textinput.html">TextInput</a> key handling</li>
<li>Items specified in <code>forwardTo</code></li>
<li>specific key handlers, e.g&#x2e; onReturnPressed</li>
<li>onPressed, onReleased handlers</li>
<li>parent item</li>
</ol>
<p>If the event is accepted during any of the above steps, key propagation stops.</p>
<p><b>请参考 </b><a href="qml-qtquick-keyevent.html">KeyEvent</a> 和 <a href="qml-qtquick-keynavigation.html">KeyNavigation attached property</a>。</p>
<!-- @@@Keys -->
<h2>属性文档</h2>
<!-- $$$enabled -->
<div class="qmlitem"><div class="qmlproto">
<div class="table"><table class="qmlname">
<tr valign="top" class="odd" id="enabled-prop">
<td class="tblQmlPropNode"><p>
<a name="enabled-prop"></a><span class="name">enabled</span> : <span class="type"><a href="../qtqml/qml-bool.html">bool</a></span></p></td></tr>
</table></div>
</div><div class="qmldoc"><p>This flags enables key handling if true (default); otherwise no key handlers will be called.</p>
</div></div><!-- @@@enabled -->
<br/>
<!-- $$$forwardTo -->
<div class="qmlitem"><div class="qmlproto">
<div class="table"><table class="qmlname">
<tr valign="top" class="odd" id="forwardTo-prop">
<td class="tblQmlPropNode"><p>
<a name="forwardTo-prop"></a><span class="name">forwardTo</span> : <span class="type"><a href="../qtqml/qml-list.html">list</a></span>&lt;<span class="type">Object</span>&gt;</p></td></tr>
</table></div>
</div><div class="qmldoc"><p>This property provides a way to forward key presses, key releases, and keyboard input coming from input methods to other items. This can be useful when you want one item to handle some keys (e.g&#x2e; the up and down arrow keys), and another item to handle other keys (e.g&#x2e; the left and right arrow keys). Once an item that has been forwarded keys accepts the event it is no longer forwarded to items later in the list.</p>
<p>This example forwards key events to two lists:</p>
<pre class="qml">

  <span class="type"><a href="qml-qtquick-item.html">Item</a></span> {
      <span class="type"><a href="qml-qtquick-listview.html">ListView</a></span> {
          <span class="name">id</span>: <span class="name">list1</span>
          <span class="comment">// ...</span>
      }
      <span class="type"><a href="qml-qtquick-listview.html">ListView</a></span> {
          <span class="name">id</span>: <span class="name">list2</span>
          <span class="comment">// ...</span>
      }
      <span class="name">Keys</span>.forwardTo: [<span class="name">list1</span>, <span class="name">list2</span>]
      <span class="name">focus</span>: <span class="number">true</span>
  }

</pre>
<p>To see the order in which events are received when using forwardTo, see <a href="qml-qtquick-keys.html#key-handling-priorities">Key Handling Priorities</a>.</p>
</div></div><!-- @@@forwardTo -->
<br/>
<!-- $$$priority -->
<div class="qmlitem"><div class="qmlproto">
<div class="table"><table class="qmlname">
<tr valign="top" class="odd" id="priority-prop">
<td class="tblQmlPropNode"><p>
<a name="priority-prop"></a><span class="name">priority</span> : <span class="type"><a href="../qtqml/qml-enumeration.html">enumeration</a></span></p></td></tr>
</table></div>
</div><div class="qmldoc"><p>This property determines whether the keys are processed before or after the attached item's own key handling.</p>
<ul>
<li>Keys.BeforeItem (default) - process the key events before normal item key processing. If the event is accepted it will not be passed on to the item.</li>
<li>Keys.AfterItem - process the key events after normal item key handling. If the item accepts the key event it will not be handled by the Keys attached property handler.</li>
</ul>
<p><b>请参考 </b><a href="qml-qtquick-keys.html#key-handling-priorities">Key Handling Priorities</a>。</p>
</div></div><!-- @@@priority -->
<br/>
<h2>Signal Documentation</h2>
<!-- $$$asteriskPressed -->
<div class="qmlitem"><div class="qmlproto">
<div class="table"><table class="qmlname">
<tr valign="top" class="odd" id="asteriskPressed-signal">
<td class="tblQmlFuncNode"><p>
<a name="asteriskPressed-signal"></a><span class="name">asteriskPressed</span>(<span class="type"><a href="qml-qtquick-keyevent.html">KeyEvent</a></span> <i>event</i>)</p></td></tr>
</table></div>
</div><div class="qmldoc"><p>This signal is emitted when the Asterisk '*' has been pressed. The <i>event</i> parameter provides information about the event.</p>
<p>The corresponding handler is <code>onAsteriskPressed</code>.</p>
</div></div><!-- @@@asteriskPressed -->
<br/>
<!-- $$$backPressed -->
<div class="qmlitem"><div class="qmlproto">
<div class="table"><table class="qmlname">
<tr valign="top" class="odd" id="backPressed-signal">
<td class="tblQmlFuncNode"><p>
<a name="backPressed-signal"></a><span class="name">backPressed</span>(<span class="type"><a href="qml-qtquick-keyevent.html">KeyEvent</a></span> <i>event</i>)</p></td></tr>
</table></div>
</div><div class="qmldoc"><p>This signal is emitted when the Back key has been pressed. The <i>event</i> parameter provides information about the event.</p>
<p>The corresponding handler is <code>onBackPressed</code>.</p>
</div></div><!-- @@@backPressed -->
<br/>
<!-- $$$backtabPressed -->
<div class="qmlitem"><div class="qmlproto">
<div class="table"><table class="qmlname">
<tr valign="top" class="odd" id="backtabPressed-signal">
<td class="tblQmlFuncNode"><p>
<a name="backtabPressed-signal"></a><span class="name">backtabPressed</span>(<span class="type"><a href="qml-qtquick-keyevent.html">KeyEvent</a></span> <i>event</i>)</p></td></tr>
</table></div>
</div><div class="qmldoc"><p>This signal is emitted when the Shift+Tab key combination (Backtab) has been pressed. The <i>event</i> parameter provides information about the event.</p>
<p>The corresponding handler is <code>onBacktabPressed</code>.</p>
</div></div><!-- @@@backtabPressed -->
<br/>
<!-- $$$callPressed -->
<div class="qmlitem"><div class="qmlproto">
<div class="table"><table class="qmlname">
<tr valign="top" class="odd" id="callPressed-signal">
<td class="tblQmlFuncNode"><p>
<a name="callPressed-signal"></a><span class="name">callPressed</span>(<span class="type"><a href="qml-qtquick-keyevent.html">KeyEvent</a></span> <i>event</i>)</p></td></tr>
</table></div>
</div><div class="qmldoc"><p>This signal is emitted when the Call key has been pressed. The <i>event</i> parameter provides information about the event.</p>
<p>The corresponding handler is <code>onCallPressed</code>.</p>
</div></div><!-- @@@callPressed -->
<br/>
<!-- $$$cancelPressed -->
<div class="qmlitem"><div class="qmlproto">
<div class="table"><table class="qmlname">
<tr valign="top" class="odd" id="cancelPressed-signal">
<td class="tblQmlFuncNode"><p>
<a name="cancelPressed-signal"></a><span class="name">cancelPressed</span>(<span class="type"><a href="qml-qtquick-keyevent.html">KeyEvent</a></span> <i>event</i>)</p></td></tr>
</table></div>
</div><div class="qmldoc"><p>This signal is emitted when the Cancel key has been pressed. The <i>event</i> parameter provides information about the event.</p>
<p>The corresponding handler is <code>onCancelPressed</code>.</p>
</div></div><!-- @@@cancelPressed -->
<br/>
<!-- $$$context1Pressed -->
<div class="qmlitem"><div class="qmlproto">
<div class="table"><table class="qmlname">
<tr valign="top" class="odd" id="context1Pressed-signal">
<td class="tblQmlFuncNode"><p>
<a name="context1Pressed-signal"></a><span class="name">context1Pressed</span>(<span class="type"><a href="qml-qtquick-keyevent.html">KeyEvent</a></span> <i>event</i>)</p></td></tr>
</table></div>
</div><div class="qmldoc"><p>This signal is emitted when the Context1 key has been pressed. The <i>event</i> parameter provides information about the event.</p>
<p>The corresponding handler is <code>onContext1Pressed</code>.</p>
</div></div><!-- @@@context1Pressed -->
<br/>
<!-- $$$context2Pressed -->
<div class="qmlitem"><div class="qmlproto">
<div class="table"><table class="qmlname">
<tr valign="top" class="odd" id="context2Pressed-signal">
<td class="tblQmlFuncNode"><p>
<a name="context2Pressed-signal"></a><span class="name">context2Pressed</span>(<span class="type"><a href="qml-qtquick-keyevent.html">KeyEvent</a></span> <i>event</i>)</p></td></tr>
</table></div>
</div><div class="qmldoc"><p>This signal is emitted when the Context2 key has been pressed. The <i>event</i> parameter provides information about the event.</p>
<p>The corresponding handler is <code>onContext2Pressed</code>.</p>
</div></div><!-- @@@context2Pressed -->
<br/>
<!-- $$$context3Pressed -->
<div class="qmlitem"><div class="qmlproto">
<div class="table"><table class="qmlname">
<tr valign="top" class="odd" id="context3Pressed-signal">
<td class="tblQmlFuncNode"><p>
<a name="context3Pressed-signal"></a><span class="name">context3Pressed</span>(<span class="type"><a href="qml-qtquick-keyevent.html">KeyEvent</a></span> <i>event</i>)</p></td></tr>
</table></div>
</div><div class="qmldoc"><p>This signal is emitted when the Context3 key has been pressed. The <i>event</i> parameter provides information about the event.</p>
<p>The corresponding handler is <code>onContext3Pressed</code>.</p>
</div></div><!-- @@@context3Pressed -->
<br/>
<!-- $$$context4Pressed -->
<div class="qmlitem"><div class="qmlproto">
<div class="table"><table class="qmlname">
<tr valign="top" class="odd" id="context4Pressed-signal">
<td class="tblQmlFuncNode"><p>
<a name="context4Pressed-signal"></a><span class="name">context4Pressed</span>(<span class="type"><a href="qml-qtquick-keyevent.html">KeyEvent</a></span> <i>event</i>)</p></td></tr>
</table></div>
</div><div class="qmldoc"><p>This signal is emitted when the Context4 key has been pressed. The <i>event</i> parameter provides information about the event.</p>
<p>The corresponding handler is <code>onContext4Pressed</code>.</p>
</div></div><!-- @@@context4Pressed -->
<br/>
<!-- $$$deletePressed -->
<div class="qmlitem"><div class="qmlproto">
<div class="table"><table class="qmlname">
<tr valign="top" class="odd" id="deletePressed-signal">
<td class="tblQmlFuncNode"><p>
<a name="deletePressed-signal"></a><span class="name">deletePressed</span>(<span class="type"><a href="qml-qtquick-keyevent.html">KeyEvent</a></span> <i>event</i>)</p></td></tr>
</table></div>
</div><div class="qmldoc"><p>This signal is emitted when the Delete key has been pressed. The <i>event</i> parameter provides information about the event.</p>
<p>The corresponding handler is <code>onDeletePressed</code>.</p>
</div></div><!-- @@@deletePressed -->
<br/>
<!-- $$$digit0Pressed -->
<div class="qmlitem"><div class="qmlproto">
<div class="table"><table class="qmlname">
<tr valign="top" class="odd" id="digit0Pressed-signal">
<td class="tblQmlFuncNode"><p>
<a name="digit0Pressed-signal"></a><span class="name">digit0Pressed</span>(<span class="type"><a href="qml-qtquick-keyevent.html">KeyEvent</a></span> <i>event</i>)</p></td></tr>
</table></div>
</div><div class="qmldoc"><p>This signal is emitted when the digit '0' has been pressed. The <i>event</i> parameter provides information about the event.</p>
<p>The corresponding handler is <code>onDigit0Pressed</code>.</p>
</div></div><!-- @@@digit0Pressed -->
<br/>
<!-- $$$digit1Pressed -->
<div class="qmlitem"><div class="qmlproto">
<div class="table"><table class="qmlname">
<tr valign="top" class="odd" id="digit1Pressed-signal">
<td class="tblQmlFuncNode"><p>
<a name="digit1Pressed-signal"></a><span class="name">digit1Pressed</span>(<span class="type"><a href="qml-qtquick-keyevent.html">KeyEvent</a></span> <i>event</i>)</p></td></tr>
</table></div>
</div><div class="qmldoc"><p>This signal is emitted when the digit '1' has been pressed. The <i>event</i> parameter provides information about the event.</p>
<p>The corresponding handler is <code>onDigit1Pressed</code>.</p>
</div></div><!-- @@@digit1Pressed -->
<br/>
<!-- $$$digit2Pressed -->
<div class="qmlitem"><div class="qmlproto">
<div class="table"><table class="qmlname">
<tr valign="top" class="odd" id="digit2Pressed-signal">
<td class="tblQmlFuncNode"><p>
<a name="digit2Pressed-signal"></a><span class="name">digit2Pressed</span>(<span class="type"><a href="qml-qtquick-keyevent.html">KeyEvent</a></span> <i>event</i>)</p></td></tr>
</table></div>
</div><div class="qmldoc"><p>This signal is emitted when the digit '2' has been pressed. The <i>event</i> parameter provides information about the event.</p>
<p>The corresponding handler is <code>onDigit2Pressed</code>.</p>
</div></div><!-- @@@digit2Pressed -->
<br/>
<!-- $$$digit3Pressed -->
<div class="qmlitem"><div class="qmlproto">
<div class="table"><table class="qmlname">
<tr valign="top" class="odd" id="digit3Pressed-signal">
<td class="tblQmlFuncNode"><p>
<a name="digit3Pressed-signal"></a><span class="name">digit3Pressed</span>(<span class="type"><a href="qml-qtquick-keyevent.html">KeyEvent</a></span> <i>event</i>)</p></td></tr>
</table></div>
</div><div class="qmldoc"><p>This signal is emitted when the digit '3' has been pressed. The <i>event</i> parameter provides information about the event.</p>
<p>The corresponding handler is <code>onDigit3Pressed</code>.</p>
</div></div><!-- @@@digit3Pressed -->
<br/>
<!-- $$$digit4Pressed -->
<div class="qmlitem"><div class="qmlproto">
<div class="table"><table class="qmlname">
<tr valign="top" class="odd" id="digit4Pressed-signal">
<td class="tblQmlFuncNode"><p>
<a name="digit4Pressed-signal"></a><span class="name">digit4Pressed</span>(<span class="type"><a href="qml-qtquick-keyevent.html">KeyEvent</a></span> <i>event</i>)</p></td></tr>
</table></div>
</div><div class="qmldoc"><p>This signal is emitted when the digit '4' has been pressed. The <i>event</i> parameter provides information about the event.</p>
<p>The corresponding handler is <code>onDigit4Pressed</code>.</p>
</div></div><!-- @@@digit4Pressed -->
<br/>
<!-- $$$digit5Pressed -->
<div class="qmlitem"><div class="qmlproto">
<div class="table"><table class="qmlname">
<tr valign="top" class="odd" id="digit5Pressed-signal">
<td class="tblQmlFuncNode"><p>
<a name="digit5Pressed-signal"></a><span class="name">digit5Pressed</span>(<span class="type"><a href="qml-qtquick-keyevent.html">KeyEvent</a></span> <i>event</i>)</p></td></tr>
</table></div>
</div><div class="qmldoc"><p>This signal is emitted when the digit '5' has been pressed. The <i>event</i> parameter provides information about the event.</p>
<p>The corresponding handler is <code>onDigit5Pressed</code>.</p>
</div></div><!-- @@@digit5Pressed -->
<br/>
<!-- $$$digit6Pressed -->
<div class="qmlitem"><div class="qmlproto">
<div class="table"><table class="qmlname">
<tr valign="top" class="odd" id="digit6Pressed-signal">
<td class="tblQmlFuncNode"><p>
<a name="digit6Pressed-signal"></a><span class="name">digit6Pressed</span>(<span class="type"><a href="qml-qtquick-keyevent.html">KeyEvent</a></span> <i>event</i>)</p></td></tr>
</table></div>
</div><div class="qmldoc"><p>This signal is emitted when the digit '6' has been pressed. The <i>event</i> parameter provides information about the event.</p>
<p>The corresponding handler is <code>onDigit6Pressed</code>.</p>
</div></div><!-- @@@digit6Pressed -->
<br/>
<!-- $$$digit7Pressed -->
<div class="qmlitem"><div class="qmlproto">
<div class="table"><table class="qmlname">
<tr valign="top" class="odd" id="digit7Pressed-signal">
<td class="tblQmlFuncNode"><p>
<a name="digit7Pressed-signal"></a><span class="name">digit7Pressed</span>(<span class="type"><a href="qml-qtquick-keyevent.html">KeyEvent</a></span> <i>event</i>)</p></td></tr>
</table></div>
</div><div class="qmldoc"><p>This signal is emitted when the digit '7' has been pressed. The <i>event</i> parameter provides information about the event.</p>
<p>The corresponding handler is <code>onDigit7Pressed</code>.</p>
</div></div><!-- @@@digit7Pressed -->
<br/>
<!-- $$$digit8Pressed -->
<div class="qmlitem"><div class="qmlproto">
<div class="table"><table class="qmlname">
<tr valign="top" class="odd" id="digit8Pressed-signal">
<td class="tblQmlFuncNode"><p>
<a name="digit8Pressed-signal"></a><span class="name">digit8Pressed</span>(<span class="type"><a href="qml-qtquick-keyevent.html">KeyEvent</a></span> <i>event</i>)</p></td></tr>
</table></div>
</div><div class="qmldoc"><p>This signal is emitted when the digit '8' has been pressed. The <i>event</i> parameter provides information about the event.</p>
<p>The corresponding handler is <code>onDigit8Pressed</code>.</p>
</div></div><!-- @@@digit8Pressed -->
<br/>
<!-- $$$digit9Pressed -->
<div class="qmlitem"><div class="qmlproto">
<div class="table"><table class="qmlname">
<tr valign="top" class="odd" id="digit9Pressed-signal">
<td class="tblQmlFuncNode"><p>
<a name="digit9Pressed-signal"></a><span class="name">digit9Pressed</span>(<span class="type"><a href="qml-qtquick-keyevent.html">KeyEvent</a></span> <i>event</i>)</p></td></tr>
</table></div>
</div><div class="qmldoc"><p>This signal is emitted when the digit '9' has been pressed. The <i>event</i> parameter provides information about the event.</p>
<p>The corresponding handler is <code>onDigit9Pressed</code>.</p>
</div></div><!-- @@@digit9Pressed -->
<br/>
<!-- $$$downPressed -->
<div class="qmlitem"><div class="qmlproto">
<div class="table"><table class="qmlname">
<tr valign="top" class="odd" id="downPressed-signal">
<td class="tblQmlFuncNode"><p>
<a name="downPressed-signal"></a><span class="name">downPressed</span>(<span class="type"><a href="qml-qtquick-keyevent.html">KeyEvent</a></span> <i>event</i>)</p></td></tr>
</table></div>
</div><div class="qmldoc"><p>This signal is emitted when the Down arrow has been pressed. The <i>event</i> parameter provides information about the event.</p>
<p>The corresponding handler is <code>onDownPressed</code>.</p>
</div></div><!-- @@@downPressed -->
<br/>
<!-- $$$enterPressed -->
<div class="qmlitem"><div class="qmlproto">
<div class="table"><table class="qmlname">
<tr valign="top" class="odd" id="enterPressed-signal">
<td class="tblQmlFuncNode"><p>
<a name="enterPressed-signal"></a><span class="name">enterPressed</span>(<span class="type"><a href="qml-qtquick-keyevent.html">KeyEvent</a></span> <i>event</i>)</p></td></tr>
</table></div>
</div><div class="qmldoc"><p>This signal is emitted when the Enter key has been pressed. The <i>event</i> parameter provides information about the event.</p>
<p>The corresponding handler is <code>onEnterPressed</code>.</p>
</div></div><!-- @@@enterPressed -->
<br/>
<!-- $$$escapePressed -->
<div class="qmlitem"><div class="qmlproto">
<div class="table"><table class="qmlname">
<tr valign="top" class="odd" id="escapePressed-signal">
<td class="tblQmlFuncNode"><p>
<a name="escapePressed-signal"></a><span class="name">escapePressed</span>(<span class="type"><a href="qml-qtquick-keyevent.html">KeyEvent</a></span> <i>event</i>)</p></td></tr>
</table></div>
</div><div class="qmldoc"><p>This signal is emitted when the Escape key has been pressed. The <i>event</i> parameter provides information about the event.</p>
<p>The corresponding handler is <code>onEscapePressed</code>.</p>
</div></div><!-- @@@escapePressed -->
<br/>
<!-- $$$flipPressed -->
<div class="qmlitem"><div class="qmlproto">
<div class="table"><table class="qmlname">
<tr valign="top" class="odd" id="flipPressed-signal">
<td class="tblQmlFuncNode"><p>
<a name="flipPressed-signal"></a><span class="name">flipPressed</span>(<span class="type"><a href="qml-qtquick-keyevent.html">KeyEvent</a></span> <i>event</i>)</p></td></tr>
</table></div>
</div><div class="qmldoc"><p>This signal is emitted when the Flip key has been pressed. The <i>event</i> parameter provides information about the event.</p>
<p>The corresponding handler is <code>onFlipPressed</code>.</p>
</div></div><!-- @@@flipPressed -->
<br/>
<!-- $$$hangupPressed -->
<div class="qmlitem"><div class="qmlproto">
<div class="table"><table class="qmlname">
<tr valign="top" class="odd" id="hangupPressed-signal">
<td class="tblQmlFuncNode"><p>
<a name="hangupPressed-signal"></a><span class="name">hangupPressed</span>(<span class="type"><a href="qml-qtquick-keyevent.html">KeyEvent</a></span> <i>event</i>)</p></td></tr>
</table></div>
</div><div class="qmldoc"><p>This signal is emitted when the Hangup key has been pressed. The <i>event</i> parameter provides information about the event.</p>
<p>The corresponding handler is <code>onHangupPressed</code>.</p>
</div></div><!-- @@@hangupPressed -->
<br/>
<!-- $$$leftPressed -->
<div class="qmlitem"><div class="qmlproto">
<div class="table"><table class="qmlname">
<tr valign="top" class="odd" id="leftPressed-signal">
<td class="tblQmlFuncNode"><p>
<a name="leftPressed-signal"></a><span class="name">leftPressed</span>(<span class="type"><a href="qml-qtquick-keyevent.html">KeyEvent</a></span> <i>event</i>)</p></td></tr>
</table></div>
</div><div class="qmldoc"><p>This signal is emitted when the Left arrow has been pressed. The <i>event</i> parameter provides information about the event.</p>
<p>The corresponding handler is <code>onLeftPressed</code>.</p>
</div></div><!-- @@@leftPressed -->
<br/>
<!-- $$$menuPressed -->
<div class="qmlitem"><div class="qmlproto">
<div class="table"><table class="qmlname">
<tr valign="top" class="odd" id="menuPressed-signal">
<td class="tblQmlFuncNode"><p>
<a name="menuPressed-signal"></a><span class="name">menuPressed</span>(<span class="type"><a href="qml-qtquick-keyevent.html">KeyEvent</a></span> <i>event</i>)</p></td></tr>
</table></div>
</div><div class="qmldoc"><p>This signal is emitted when the Menu key has been pressed. The <i>event</i> parameter provides information about the event.</p>
<p>The corresponding handler is <code>onMenuPressed</code>.</p>
</div></div><!-- @@@menuPressed -->
<br/>
<!-- $$$noPressed -->
<div class="qmlitem"><div class="qmlproto">
<div class="table"><table class="qmlname">
<tr valign="top" class="odd" id="noPressed-signal">
<td class="tblQmlFuncNode"><p>
<a name="noPressed-signal"></a><span class="name">noPressed</span>(<span class="type"><a href="qml-qtquick-keyevent.html">KeyEvent</a></span> <i>event</i>)</p></td></tr>
</table></div>
</div><div class="qmldoc"><p>This signal is emitted when the No key has been pressed. The <i>event</i> parameter provides information about the event.</p>
<p>The corresponding handler is <code>onNoPressed</code>.</p>
</div></div><!-- @@@noPressed -->
<br/>
<!-- $$$pressed -->
<div class="qmlitem"><div class="qmlproto">
<div class="table"><table class="qmlname">
<tr valign="top" class="odd" id="pressed-signal">
<td class="tblQmlFuncNode"><p>
<a name="pressed-signal"></a><span class="name">pressed</span>(<span class="type"><a href="qml-qtquick-keyevent.html">KeyEvent</a></span> <i>event</i>)</p></td></tr>
</table></div>
</div><div class="qmldoc"><p>This signal is emitted when a key has been pressed. The <i>event</i> parameter provides information about the event.</p>
<p>The corresponding handler is <code>onPressed</code>.</p>
</div></div><!-- @@@pressed -->
<br/>
<!-- $$$released -->
<div class="qmlitem"><div class="qmlproto">
<div class="table"><table class="qmlname">
<tr valign="top" class="odd" id="released-signal">
<td class="tblQmlFuncNode"><p>
<a name="released-signal"></a><span class="name">released</span>(<span class="type"><a href="qml-qtquick-keyevent.html">KeyEvent</a></span> <i>event</i>)</p></td></tr>
</table></div>
</div><div class="qmldoc"><p>This signal is emitted when a key has been released. The <i>event</i> parameter provides information about the event.</p>
<p>The corresponding handler is <code>onReleased</code>.</p>
</div></div><!-- @@@released -->
<br/>
<!-- $$$returnPressed -->
<div class="qmlitem"><div class="qmlproto">
<div class="table"><table class="qmlname">
<tr valign="top" class="odd" id="returnPressed-signal">
<td class="tblQmlFuncNode"><p>
<a name="returnPressed-signal"></a><span class="name">returnPressed</span>(<span class="type"><a href="qml-qtquick-keyevent.html">KeyEvent</a></span> <i>event</i>)</p></td></tr>
</table></div>
</div><div class="qmldoc"><p>This signal is emitted when the Return key has been pressed. The <i>event</i> parameter provides information about the event.</p>
<p>The corresponding handler is <code>onReturnPressed</code>.</p>
</div></div><!-- @@@returnPressed -->
<br/>
<!-- $$$rightPressed -->
<div class="qmlitem"><div class="qmlproto">
<div class="table"><table class="qmlname">
<tr valign="top" class="odd" id="rightPressed-signal">
<td class="tblQmlFuncNode"><p>
<a name="rightPressed-signal"></a><span class="name">rightPressed</span>(<span class="type"><a href="qml-qtquick-keyevent.html">KeyEvent</a></span> <i>event</i>)</p></td></tr>
</table></div>
</div><div class="qmldoc"><p>This signal is emitted when the Right arrow has been pressed. The <i>event</i> parameter provides information about the event.</p>
<p>The corresponding handler is <code>onRightPressed</code>.</p>
</div></div><!-- @@@rightPressed -->
<br/>
<!-- $$$selectPressed -->
<div class="qmlitem"><div class="qmlproto">
<div class="table"><table class="qmlname">
<tr valign="top" class="odd" id="selectPressed-signal">
<td class="tblQmlFuncNode"><p>
<a name="selectPressed-signal"></a><span class="name">selectPressed</span>(<span class="type"><a href="qml-qtquick-keyevent.html">KeyEvent</a></span> <i>event</i>)</p></td></tr>
</table></div>
</div><div class="qmldoc"><p>This signal is emitted when the Select key has been pressed. The <i>event</i> parameter provides information about the event.</p>
<p>The corresponding handler is <code>onSelectPressed</code>.</p>
</div></div><!-- @@@selectPressed -->
<br/>
<!-- $$$shortcutOverride -->
<div class="qmlitem"><div class="qmlproto">
<div class="table"><table class="qmlname">
<tr valign="top" class="odd" id="shortcutOverride-signal">
<td class="tblQmlFuncNode"><p>
<a name="shortcutOverride-signal"></a><span class="name">shortcutOverride</span>(<span class="type"><a href="qml-qtquick-keyevent.html">KeyEvent</a></span> <i>event</i>)</p></td></tr>
</table></div>
</div><div class="qmldoc"><p>This signal is emitted when a key has been pressed that could potentially be used as a shortcut. The <i>event</i> parameter provides information about the event.</p>
<p>Set <code>event.accepted</code> to <code>true</code> if you wish to prevent the pressed key from being used as a shortcut by other types, such as <a href="qml-qtquick-shortcut.html">Shortcut</a>. For example:</p>
<pre class="cpp">

  Item {
      id: escapeItem
      focus: <span class="keyword">true</span>

      <span class="comment">// Ensure that we get escape key press events first.</span>
      Keys<span class="operator">.</span>onShortcutOverride: event<span class="operator">.</span>accepted <span class="operator">=</span> (event<span class="operator">.</span>key <span class="operator">=</span><span class="operator">=</span><span class="operator">=</span> <span class="type"><a href="../qtqml/qml-qtqml-qt.html">Qt</a></span><span class="operator">.</span>Key_Escape)

      Keys<span class="operator">.</span>onEscapePressed: {
          console<span class="operator">.</span>log(<span class="string">&quot;escapeItem is handling escape&quot;</span>);
          <span class="comment">// event.accepted is set to true by default for the specific key handlers</span>
      }
  }

  Shortcut {
      sequence: <span class="string">&quot;Escape&quot;</span>
      onActivated: console<span class="operator">.</span>log(<span class="string">&quot;Shortcut is handling escape&quot;</span>)
  }

</pre>
<p>As with the other signals, <code>shortcutOverride</code> will only be emitted for an item if that item has <a href="qml-qtquick-item.html#activeFocus-prop">activeFocus</a>.</p>
<p>The corresponding handler is <code>onShortcutOverride</code>.</p>
<p>This signal was introduced in  Qt 5.9.</p>
<p><b>请参考 </b><a href="qml-qtquick-shortcut.html">Shortcut</a>。</p>
</div></div><!-- @@@shortcutOverride -->
<br/>
<!-- $$$spacePressed -->
<div class="qmlitem"><div class="qmlproto">
<div class="table"><table class="qmlname">
<tr valign="top" class="odd" id="spacePressed-signal">
<td class="tblQmlFuncNode"><p>
<a name="spacePressed-signal"></a><span class="name">spacePressed</span>(<span class="type"><a href="qml-qtquick-keyevent.html">KeyEvent</a></span> <i>event</i>)</p></td></tr>
</table></div>
</div><div class="qmldoc"><p>This signal is emitted when the Space key has been pressed. The <i>event</i> parameter provides information about the event.</p>
<p>The corresponding handler is <code>onSpacePressed</code>.</p>
</div></div><!-- @@@spacePressed -->
<br/>
<!-- $$$tabPressed -->
<div class="qmlitem"><div class="qmlproto">
<div class="table"><table class="qmlname">
<tr valign="top" class="odd" id="tabPressed-signal">
<td class="tblQmlFuncNode"><p>
<a name="tabPressed-signal"></a><span class="name">tabPressed</span>(<span class="type"><a href="qml-qtquick-keyevent.html">KeyEvent</a></span> <i>event</i>)</p></td></tr>
</table></div>
</div><div class="qmldoc"><p>This signal is emitted when the Tab key has been pressed. The <i>event</i> parameter provides information about the event.</p>
<p>The corresponding handler is <code>onTabPressed</code>.</p>
</div></div><!-- @@@tabPressed -->
<br/>
<!-- $$$upPressed -->
<div class="qmlitem"><div class="qmlproto">
<div class="table"><table class="qmlname">
<tr valign="top" class="odd" id="upPressed-signal">
<td class="tblQmlFuncNode"><p>
<a name="upPressed-signal"></a><span class="name">upPressed</span>(<span class="type"><a href="qml-qtquick-keyevent.html">KeyEvent</a></span> <i>event</i>)</p></td></tr>
</table></div>
</div><div class="qmldoc"><p>This signal is emitted when the Up arrow has been pressed. The <i>event</i> parameter provides information about the event.</p>
<p>The corresponding handler is <code>onUpPressed</code>.</p>
</div></div><!-- @@@upPressed -->
<br/>
<!-- $$$volumeDownPressed -->
<div class="qmlitem"><div class="qmlproto">
<div class="table"><table class="qmlname">
<tr valign="top" class="odd" id="volumeDownPressed-signal">
<td class="tblQmlFuncNode"><p>
<a name="volumeDownPressed-signal"></a><span class="name">volumeDownPressed</span>(<span class="type"><a href="qml-qtquick-keyevent.html">KeyEvent</a></span> <i>event</i>)</p></td></tr>
</table></div>
</div><div class="qmldoc"><p>This signal is emitted when the VolumeDown key has been pressed. The <i>event</i> parameter provides information about the event.</p>
<p>The corresponding handler is <code>onVolumeDownPressed</code>.</p>
</div></div><!-- @@@volumeDownPressed -->
<br/>
<!-- $$$volumeUpPressed -->
<div class="qmlitem"><div class="qmlproto">
<div class="table"><table class="qmlname">
<tr valign="top" class="odd" id="volumeUpPressed-signal">
<td class="tblQmlFuncNode"><p>
<a name="volumeUpPressed-signal"></a><span class="name">volumeUpPressed</span>(<span class="type"><a href="qml-qtquick-keyevent.html">KeyEvent</a></span> <i>event</i>)</p></td></tr>
</table></div>
</div><div class="qmldoc"><p>This signal is emitted when the VolumeUp key has been pressed. The <i>event</i> parameter provides information about the event.</p>
<p>The corresponding handler is <code>onVolumeUpPressed</code>.</p>
</div></div><!-- @@@volumeUpPressed -->
<br/>
<!-- $$$yesPressed -->
<div class="qmlitem"><div class="qmlproto">
<div class="table"><table class="qmlname">
<tr valign="top" class="odd" id="yesPressed-signal">
<td class="tblQmlFuncNode"><p>
<a name="yesPressed-signal"></a><span class="name">yesPressed</span>(<span class="type"><a href="qml-qtquick-keyevent.html">KeyEvent</a></span> <i>event</i>)</p></td></tr>
</table></div>
</div><div class="qmldoc"><p>This signal is emitted when the Yes key has been pressed. The <i>event</i> parameter provides information about the event.</p>
<p>The corresponding handler is <code>onYesPressed</code>.</p>
</div></div><!-- @@@yesPressed -->
<br/>
        </div>
       </div>
   </div>
   </div>
</div>
<div class="footer">
   <p>
   <acronym title="Copyright">&copy;</acronym> 2019 The Qt Company Ltd.
   Documentation contributions included herein are the copyrights of
   their respective owners.<br/>    The documentation provided herein is licensed under the terms of the    <a href="http://www.gnu.org/licenses/fdl.html">GNU Free Documentation    License version 1.3</a> as published by the Free Software Foundation.<br/>    Qt and respective logos are trademarks of The Qt Company Ltd.     in Finland and/or other countries worldwide. All other trademarks are property
   of their respective owners. </p>
</div>
</body>
</html>
